package com.bicon.botu.mall.order.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.bicon.botu.mall.order.dto.OrderItemDto;
import com.bicon.botu.mall.order.entity.OrderItem;
import com.bicon.botu.mall.order.mapper.OrderItemMapper;
import com.bicon.botu.mall.order.service.IOrderItemService;
import com.bicon.botu.core.base.common.Constants;
import com.bicon.botu.core.base.common.entity.BaseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 订单服务实现
 *
 * @auther 裴志鹏
 * @date 2017/7/20 16:05
 */
@Slf4j
@Service
@Transactional
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem> implements IOrderItemService {


//    @Autowired
//    private ProductRpc productRpc;

    @Autowired
    private OrderItemMapper orderItemMapper;

    /**
     * 通过订单id查询商品详情
     *
     * @param orderId 订单id
     * @return
     */
    @Override
    public BaseResult findGoodsByOrderId(String orderId) {
        Map<String, Object> map = new HashMap<>();
        map.put("logicDelete", Constants.DEL_LOGIC_NORMAL);
        map.put("orderId", orderId);
        List<OrderItemDto> orderItemDtoList = orderItemMapper.findOrderItemByOrderId(map);
        if (orderItemDtoList==null||orderItemDtoList.size()<0){
            return new BaseResult(Constants.RESPONSE_CODE_602,Constants.RESPONSE_MESSAGE_602);
        }
        return new BaseResult(Constants.RESPONSE_CODE_200, Constants.RESPONSE_MESSAGE_200,orderItemDtoList);
    }
}
